package ee.ttu.rakarh.commands;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CommandFactory {
	public Command getCommand(HttpServletRequest req, HttpServletResponse res){
		Command command = new DummyCommand();
		String action = req.getParameter("a");
		return processCommand(action);
	}
	
	public Command processCommand(String action){
		Command command = new DummyCommand();

		if(action.equals("addItem"))
			command = new PrepareNewItemForm();
		if(action.equals("kataloog"))
			command = new GetItemsAndTypes();
		if(action.equals("searchItem"))
			command = new GetItemSearchResults();
		if(action.equals("saveItem"))
			command = new AddItem();
		if(action.equals("login"))
			command = new Login();
		if(action.equals("logout"))
			command = new Logout();
		if(action.equals("getUpdateItemForm"))
			command = new GetUpdateItemForm();
		if(action.equals("updateItem"))
			command = new UpdateItem();
		if(action.equals("getItem"))
			command = new GetUpdateItemForm();
		if(action.equals("priceList"))
			command = new GetPriceLists();
		if(action.equals("addPriceListForm"))
			command = new PrepareAddPriceListForm();
		if(action.equals("getCheckInForm")
		|| action.equals("getCheckOutForm")
		|| action.equals("getChangeStoreForm"))
			command = new GetStoresCommand();
		if(action.equals("addToStore"))
			command = new AddToStoreCommand();
		if(action.equals("removeFromStore"))
			command = new RemoveFromStoreCommand();
		if(action.equals("searchItemResults"))
			command = new SearchItemCommand();
		
		return command;
	}
}
